<template>
	<view class="content">
		<view class="main-content">
			<view class="content-title">
				<text>商家收款</text>
			</view>
			<image :src="headImg" class="eName"></image>
			<text class="cName">{{mchName}}</text>
			<view class="img">
				<image :src="qrCode" mode=""></image>
			</view>
			<text class="find">扫一扫</text>
		</view>
	</view>
</template>

<script>
	import uniIcon from "@/components/uni-icon/uni-icon.vue";
	import eonfox from '@/components/eonfox/eonfox.js';
	import fns from '@/components/eonfox/fns.js';
	var ef=new eonfox();
	export default {
		data(){
			return{
				mchName:'未设置',
				headImg:'../../static/wode.png',
				qrCode:'',
				qiniu:''
			}
		},
		components: {uniIcon},
		onLoad() {
			this.getUserInfo()
			this.getQrCode()
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			getQrCode(){
				var _this=this
				ef.left_token(function(left_token){
					//encodeURIComponent  encodeURI
					var qrCode=ef.api_server_url+"?"+encodeURI('data='+JSON.stringify([
						['MERCHANTUSERSELFQRCODEMONEYPLUS']
					]))+"&token="+left_token+"&time="+Date.now();
					_this.qrCode=qrCode
					console.log('二维码：',qrCode);
				});
				
			},
			getUserInfo(){
				var _this=this;
				ef.submit({
					request:{config:['APPLICATIONCONFIG'],mch:['MERCHANTSELF']},
					callback(data){
						var re=fns.checkError(data,['config','mch'],function(errno,error){
							uni.showToast({
								title:error,
								icon:'none'
							})
						})
						if(re.config && re.config.qiniu_domain){
							_this.qiniu=re.config.qiniu_domain
						}
						if(re.mch[0]){
							_this.mchName=re.mch[0].name;
							_this.headImg=_this.qiniu+re.mch[0].logo_image_id
						}
						console.log('qiniu && mch : ',re);
					}
				})
			}
		}
	}
</script>

<style scoped lang="stylus" ref="stylesheet/stylus">
	.content
		width 100%
		margin-top 70upx
		background-color #fff
		.title-box
			width 100%
			height 60px
			padding-left 15px
			line-height 60px
			background #fff
			border-bottom 1px solid #ccc
			.icon 
				margin-top -5px
			
		.main-content
			width calc(90% - 2upx)
			height 460px
			margin 0 auto
			background-color #fff
			border-right 1upx solid #ccc
			border-left 1upx solid #ccc
			border-bottom 1px solid #ccc
			.content-title
				width calc(100% - 20upx)
				height 60px
				margin 20px 0
				line-height 60px
				color #fff
				padding-left 20upx
				background-color green
			.eName
				background-color #fff
				display block
				width 120px
				height 120px
				line-height 120px
				font-size 28px
				color #fff
				text-align center
				margin 0 auto
				border-radius 50%
				border 1px solid #ccc
				background-color orange
			.cName
				display block
				font-size 28px
				width 100%
				height 40px
				color #2973E3
				margin 10px auto
				text-align center
			.img
				width 140px
				margin 0 auto
				image
					width 140px
					height 140px
			.find
				display block
				width 100%
				text-align center
				margin-top 10px
				font-size 14px
				
</style>
